package cn.gjculture.shopping.api.controller;

import cn.gjculture.shopping.api.entity.Insurance;
import cn.gjculture.shopping.api.entity.PageInfo;
import cn.gjculture.shopping.api.entity.Return;
import cn.gjculture.shopping.api.service.InsuranceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/insurance")
public class InsuranceController {

    @Autowired
    InsuranceService insuranceService;

    @PostMapping
    public Return insert(Insurance insurance){
        Return ret=new Return();
        int i=insuranceService.insert(insurance);
        if(i>0){
            ret.getCommon().setRet(true);
        }
        return ret;
    }

    @GetMapping
    public Return<List<Insurance>> query(PageInfo pageInfo){
        Return<List<Insurance>> ret=new Return<>();
        List<Insurance> insurances=insuranceService.query();
        ret.getCommon().setRet(true);
        ret.setData(insurances);
        return ret;
    }



}
